<?php 
$sql = "SELECT `Civilian Labor Force - Employed` , `Civilian Labor Force - Unemployed` , `Armed Forces` , `Not in Labor Force` FROM `ZipCode Profile3` WHERE `ZCTA5` = $zipcode";
		
$result = mysql_query($sql,$db);
//$num_rows = mysql_num_rows($result);
if ($result)
{
	$result_row = mysql_fetch_array($result,MYSQL_ASSOC);
	if($result_row)
	{
		$employed_civilian_pop = $result_row['Civilian Labor Force - Employed'];
		$unemployed_civilian_pop = $result_row['Civilian Labor Force - Unemployed'];
		$armed_force_pop = $result_row['Armed Forces'];
		$not_labor_pop= $result_row['Not in Labor Force'] ;
		
	}
}
$sql_1 = "SELECT `Total Population` from`ZipCode Profile1` WHERE `ZCTA5` = $zipcode";
$result_1 = mysql_query($sql_1,$db);
if ($result_1)
{
	$result_row_1 = mysql_fetch_array($result_1,MYSQL_ASSOC);
	if($result_row_1)
	{
		$total_pop = $result_row_1['Total Population'];		
	}
}

if($total_pop != 0)
{
$employed_civilian_percet = number_format((100*$employed_civilian_pop)/$total_pop,2);
$unemployed_civilian_percet = number_format((100*$unemployed_civilian_pop)/$total_pop,2);
$armed_force_percet = number_format((100*$armed_force_pop)/$total_pop,2);
$not_labor_percet = number_format((100*$not_labor_pop)/$total_pop,2);

echo "<Table width=240px cellspacing='-1' bordar=0>";
      echo "<tr style='width:100%; background:#F5DEB3; font-size:12px'>";
	  echo "<td>Employed Civilian: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$employed_civilian_pop." (".$employed_civilian_percet."%)";
	  echo "</td>";
	  echo "</tr>";
	  
	  echo "<tr style='width:100%;font-size:12px'>";
	  echo "<td>Unemployed Civilian: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$unemployed_civilian_pop." (".$unemployed_civilian_percet."%)";
	  echo "</td>";
	  echo "</tr>";
	  
      echo "<tr style='width:100%; background:#F5DEB3; font-size:12px'>";
	  echo "<td>Armed Forces: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$armed_force_pop." (".$armed_force_percet."%)";
	  echo "</td>";
	  echo "</tr>";
	  
	  echo "<tr style='width:100%;font-size:12px'>";
	  echo "<td>Not in Labor Force: ";
	  echo "</td>";
	  echo "<td align='right' nowrap='nowrap'>".$not_labor_pop." (".$not_labor_percet."%)";
	  echo "</td>";
	  echo "</tr>";
	  
echo "</Table>";
}
else
{
$nodata_msg = "Data is not available.  Please make sure the City, State and Zipcode Information is correct.";

echo "<Table width=240px cellspacing='-1' bordar=0>";
      echo "<tr style='width:100%; background:#F5DEB3; font-size:12px'>";
	  echo "<td align='right' nowrap='nowrap'>".$nodata_msg;
	  echo "</td>";

	  echo "</Table>";


}

?>